<!DOCTYPE html>
<html>
<head>
<div th:include="base-libs :: base-libs" />
<link th:href="'/quickJs/scripts/jquery/plug-ins/bootstrap-table/bootstrap-table.min.css'" rel="stylesheet">
<script th:src="'/quickJs/scripts/jquery/plug-ins/bootstrap-table/bootstrap-table.min.js'"></script>
<script th:src="'/quickJs/scripts/jquery/plug-ins/bootstrap-table/bootstrap-table-zh-CN.min.js'"></script>
<title>模板配置列表</title>
<style type="text/css">
body {
	padding: 4px;
}
.tableToolBarBtn {
	font-size: 18px;
}
</style>
<script type="text/javascript">
	$(function() {
		initView();
		$("#btnQuery").trigger("click");
	});

	function queryForm() {
		$.QuickRemote.AjaxFiledFormSubmit("queryForm", queryConditionHandler);
	}
	function queryConditionHandler(result) {
		var ary = [];
		$.each(result, function(index, item) {
			var isLinkResource = item["isLinkResource"];
			var formMetadata = item["formMetadata"];
			var id = item["_id"]["$oid"];
			var data = JSON.parse(formMetadata);
			data["BDID"] = id;
            data["isLinkResource"] = isLinkResource;
            data["MBURL"] = "/tjfx/yxpjpz/receiveYxpjView?BDID="+id;
			ary.push(data);
		})
		$("#dgForm").bootstrapTable("load", ary);
	}

	function initView() {
		$("#queryForm").attr("action", "queryYxpjpz");
		$("#dgForm").bootstrapTable({
			idField : "BDID",
			striped : true,
			method : "post",
			pagination : true,
			toolbar : "#dgFormToolbar",
			columns : [
				{
					field : "MBMC",
					title : "模板名称"
				},
                {
                    field : "MBURL",
                    title : "模版路径"
                },
                {
                    field : "isLinkResource",
                    title : "是否下钻页面",
                    formatter: function (value, row, index) {
                        if(value=="true"){
                        	return "<p style='color: #02af6d'>是</p>";
						}else{
                            return "<p style='color: red'>否</p>";
						}
                    }
                },
				{
					field : "",
					title : "操作",
					events : {
						"click .edit" : function(e, value, row, index) {
							var u = "toManager.html?BDID=" + row["BDID"];
							window.open(u);
						}
						,"click .remove" : function(e, value, row, index) {
							$.QuickAlert.alertConfirm({content:"是否删除记录", callback: function(){
								var url = "deleteYxpjpz";
								$.QuickRemote.AjaxJson(url, function(result){
									if("true" == result["state"])
									{
										$.QuickAlert.alertNormal("删除成功");
										$("#dgForm").bootstrapTable("remove", {
											field: "BDID"
											,values: [row["BDID"]]
										});
									}
									else
									{
										$.QuickAlert.alertNormal("删除失败");
									}
								}, {BDID: row["BDID"]})
							}})
						}
					},
					formatter : operateFormatter
				}
			]
		});
		
	}
	/**操作格式化*/
	function operateFormatter(value, row, index) {
		return $("#tableToolBar").html();
	}

	/**查询按钮点击回调*/
	function btnQueryHandler() {
		queryForm();
	}

	function btnAddHandler() {
		var u = "toManager.html";
		window.open(u);
	}
</script>
</head>
<body>
	<div>
		<h1>运行评价指标配置列表</h1>
	</div>
	<div id="dgFormToolbar">
		<div class="form-inline">
			<form id="queryForm">
				<div class="form-group">
					<input name="formMetadata" class="form-control" type="text"
						placeholder="请输入关键字查询">
				</div>
				<button id="btnQuery" class="btn btn-default" type="button"
					onclick="btnQueryHandler()">查询</button>
				<button id="btnAdd" class="btn btn-default" type="button"
					onclick="btnAddHandler()">新增</button>
			</form>
		</div>
	</div>
	<table id="dgForm">
	</table>

	<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="myModalLabel">下载方式选择</h4>
				</div>
				<div class="modal-body">
					<button type="button" class="btn btn-default downloadPageBtn" mode="simple">简单页面下载</button>
        			<button type="button" class="btn btn-default downloadPageBtn" mode="all">全部下载</button>
        			<button type="button" class="btn btn-default downloadPageBtn" mode="package">打包下载</button>
				</div>
				<form id="formDown" action="form/config/downPage" style="display: none;"></form>
			</div>
		</div>
	</div>
</body>
<script type="text/html" id="tableToolBar">
<a class="edit tableToolBarBtn" href="javascript:void(0)" title="修改"><i class="glyphicon glyphicon-edit"></i></a>
<a class="remove tableToolBarBtn" href="javascript:void(0)" title="删除"><i class="glyphicon glyphicon-remove"></i></a>
</script>
</html>